package com.example.prison.mapper;

import com.example.prison.entity.AlarmManagement;
import com.example.prison.entity.DefenceArea;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.prison.entity.vo.DefenceAreaVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author jiang
* @description 针对表【defence_area】的数据库操作Mapper
* @createDate 2024-06-20 14:52:58
* @Entity com.example.prison.entity.DefenceArea
*/
@Mapper
public interface DefenceAreaMapper extends BaseMapper<DefenceArea> {

    @Select("<script>select * from defence_area " +
            " <where> " +
            " <if test=\"name != null and name != ''\">and name like concat('%',#{name},'%') </if> " +
            " <if test=\"type != null and type != ''\">and type like concat('%',#{type},'%') </if> " +
            " </where> " +
            "order by sign_id desc</script>")
    List<DefenceArea> get(@Param("name") String name, @Param("type") String type);

    @Insert("insert into defence_area(id, name, type, props, shape, style, text_obj) " +
            "values (#{id}, #{name}, #{type}, #{props}, #{shape}, #{style}, #{textObj})")
    int add(DefenceArea data);

    @Delete("<script>delete from defence_area where id in <foreach collection=\"ids\" item=\"item\" open=\"(\" separator=\",\" close=\")\">#{item} </foreach> </script>")
    void deleting(@Param("ids") String[] ids);

    @Update("update defence_area " +
            "set name=#{name}, type=#{type}, props=#{props}, shape=#{shape}, style=#{style}, text=#{textObj} " +
            "where id = #{id}")
    int updating(DefenceArea data, String id);

    @Select("select * from defence_area where id=#{id}")
    DefenceArea getById(@Param("id") String id);

    @Select("select * from defence_area where name=#{name}")
    DefenceArea getByName(@Param("name") String name);

    @Delete("<script>delete from defence_area </script>")
    void deleteAll();
}




